﻿using DataBase.DBmodels;
using LiveCharts;
using LiveCharts.Wpf;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;

namespace GreenXi.Model
{
    public class CustomerVmModel : BindableBase, INotifyPropertyChanged
    {
        public string YMshare = DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString();
        public string LMshare = DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString();
        public DelegateCommand QueryCommand { get; set; }

        public ICommand ExportChartCommand { get; set; }
        public Func<double, string> Formatter { get; set; }

        public List<timeData> yearshare;
        public List<timeData> Yearshare
        {
            get { return yearshare; }
            set { SetProperty(ref yearshare, value); RaisePropertyChanged("Yearshare"); }
        }

        public static double[] temp;
        private double _xPointer;//X轴的位置
        private double _yPointer; //Y轴的位置
        //合格率情况
        public ChartValues<double> _colhSeries;
        public ChartValues<double> colhSeries
        {
            get { return _colhSeries; }
            set { SetProperty(ref _colhSeries, value); RaisePropertyChanged("colhSeries"); }
        }
        //非合格情况
        public ChartValues<double> _disqualifi;
        public ChartValues<double> Disqualifi
        {
            get { return _disqualifi; }
            set
            {
                SetProperty(ref _disqualifi, value);
                RaisePropertyChanged("Disqualifi");
            }
        }
        public string[] _colhLabels;
        public string[] colhLabels
        {
            get { return _colhLabels; }
            set
            {
                SetProperty(ref _colhLabels, value);
                RaisePropertyChanged("colhLabels");
            }
        }

        #region 产品下拉框

        private ObservableCollection<CraftView>? _CraftList;
        public ObservableCollection<CraftView>? CraftList
        {
            get => _CraftList;
            set
            {
                _CraftList = value;
            }
        }
        #endregion

        /// <summary>
        /// 开始时间
        /// </summary>
        private DateTime? _StartTime;
        public DateTime? StartTime
        {
            get => _StartTime == null ? DateTime.Now.AddMonths(-1) : _StartTime;
            set { SetProperty(ref _StartTime, value); }
        }

        /// <summary>
        /// 开始时间
        /// </summary>
        private DateTime? _EndTime;
        public DateTime? EndTime
        {
            get => _EndTime == null ? DateTime.Now : _EndTime;
            set { SetProperty(ref _EndTime, value); }
        }

        private int _CraftId;
        public int CraftId
        {
            get => _CraftId;
            set
            {
                SetProperty(ref _CraftId, value);
            }
        }

        private string _Type;
        public string Type
        {
            get => _Type;
            set
            {
                SetProperty(ref _Type, value);
            }
        }

        #region 柱状图
        private string _title;
        public string title { get { return _title; } set { SetProperty(ref _title, value); RaisePropertyChanged("title"); } }
        private string _disTitle;
        public string DisTitle
        {
            get { return _disTitle; }
            set
            {
                SetProperty(ref _disTitle, value);
                RaisePropertyChanged("DisTitle");
            }
        }

        public string year;
        public string Year
        {
            get { return year; }
            set { SetProperty(ref year, value); RaisePropertyChanged("Year"); }
        }
        public string month;
        public string Month
        {
            get { return month; }
            set { SetProperty(ref month, value); RaisePropertyChanged("Month"); }
        }


        public double XPointer
        {
            get { return _xPointer; }
            set
            {
                SetProperty(ref _xPointer, value);
                RaisePropertyChanged("XPointer");
            }
        }
        public double YPointer
        {
            get { return _yPointer; }
            set
            {
                SetProperty(ref _yPointer, value);
                RaisePropertyChanged("YPointer");
            }
        }

        #endregion
        #region 折线图
        //测试数据
        public double[] temps;
        public double[] Distemps;
        public ICommand LineCommand { get; set; }

        public string yearLine;
        public string YearLine
        {
            get { return yearLine; }
            set { SetProperty(ref yearLine, value); RaisePropertyChanged("YearLine"); }
        }
        public string monthLine;
        public string MonthLine
        {
            get { return monthLine; }
            set { SetProperty(ref monthLine, value); RaisePropertyChanged("MonthLine"); }
        }

        public string[] _lineLabels;
        public string[] LineLabels
        {
            get { return _lineLabels; }
            set
            {
                SetProperty(ref _lineLabels, value);
                RaisePropertyChanged("LineLabels");
            }
        }
        public SeriesCollection _polylinSeries;
        public SeriesCollection PolylinSeries
        {
            get { return _polylinSeries; }
            set
            {
                SetProperty(ref _polylinSeries, value);
                RaisePropertyChanged("PolylinSeries");
            }
        }
        public SeriesCollection _SeriesCollection;
        public SeriesCollection SeriesCollection
        {
            get { return _SeriesCollection; }
            set
            {
                SetProperty(ref _SeriesCollection, value);
                RaisePropertyChanged("PolylinSeries");
            }
        }


        #endregion

        private double _yMax = 100;
        public double YMax
        {
            get => _yMax;
            set
            {
                _yMax = value;
                SetProperty(ref _yMax, value);
            }
        }

    }
    public class timeData : BindableBase
    {
        public string yeser { get; set; }
    }
}
